package com.yjc.rabbitMQ.eight;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.BuiltinExchangeType;
import com.rabbitmq.client.Channel;
import com.yjc.rabbitMQ.utils.RabbitMQUtils;

/**
 * @author shkstart
 * @create 2022-08-02 12:09
 */
public class Product {

    //普通交换机
    private static final String NORMAL_EXCHANGE = "normal_exchange";
    //普通队列
    private static final String NORMAL_QUEUE = "normal_queue";
    //死信交换机
    private static final String DEAD_EXCHANGE = "dead_exchange";
    //死信队列
    private static final String DEAD_QUEUE = "normal_queue";

    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMQUtils.getChannel();
        //普通交换机
        channel.exchangeDeclare(NORMAL_EXCHANGE, BuiltinExchangeType.DIRECT);
        //死信交换机
        channel.exchangeDeclare(DEAD_EXCHANGE, BuiltinExchangeType.DIRECT);

        //设置消息超时时间(超过时间就送往死信队列)
//        AMQP.BasicProperties properties = new AMQP.BasicProperties().builder().expiration("10000").build();

        for (int i = 1; i <= 10; i++) {
            String msg = "info " + i;
            channel.basicPublish(NORMAL_EXCHANGE, "zhangsan", null, msg.getBytes("UTF-8"));
        }
    }
}
